<?php
/*
 * @Author: Wulala
 * @Date: 2025-01-23 15:28:47
 * @LastEditTime: 2025-02-06 19:09:07
 * @LastEditors: Wulala
 * @Description: 
 * @FilePath: \zhongshelife\application\api\controller\PayCode.php
 * 可以输入预定的版权声明、个性签名、空行等
 */

namespace app\api\controller;

use app\common\controller\Api;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Writer\PngWriter;

/**
 * 收款二维码
 */
class PayCode extends Api
{
    protected $noNeedLogin = [];
	protected $noNeedRight = ['*'];

    // public function index()
    // {
    //     $this->assign(['data' => '你好啊']);
    //     return $this->view->fetch('index');
    // }

    public function get_info()
    {

        $params=$this->request->post();
        
        // 获取店铺信息
        $shop_info=model('app\api\model\wanlshop\Shop')
                    ->field('shopname,avatar')
                    ->where('id',$params['shop_id'])
                    ->find();

        if(!$shop_info){
            $this->error(__('店铺不存在'));
        }

        // 获取线下扫码商品id
        $goods_id=model('app\api\model\wanlshop\Goods')
                    ->where('shop_id',$params['shop_id'])
                    ->where('huodong_type',7)
                    ->value('id');
        if(!$goods_id){
            $this->error(__('线下扫码商品不存在'));
        }            

        // 获取线下扫码商品规格id
        $sku_id=model('app\api\model\wanlshop\GoodsSku')
                    ->where('goods_id',$goods_id)
                    ->value('id');
        if(!$sku_id){
            $this->error(__('线下扫码商品规格不存在'));
        }              

        $data['shop_info'] = ['shop_name'=>$shop_info['shopname'],'avatar'=>$shop_info['avatar']] ; 
        $data['goods_info'] = ['goods_id'=>$goods_id,'sku_id'=>$sku_id] ; 

        $this->success(__('发送成功'),$data);
    }
}
